package github.pop.ares.ter;


import com.mojang.blaze3d.matrix.MatrixStack;
import github.pop.ares.block.ObsidianTERTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraftforge.client.model.data.EmptyModelData;

public class ObsidianTER extends TileEntityRenderer<ObsidianTERTileEntity> {


    public ObsidianTER(TileEntityRendererDispatcher p_i226006_1_) {
        super(p_i226006_1_);
    }

    @Override
    public void render(ObsidianTERTileEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
        // push and pop will save between all operation
        // save into matrix
        matrixStackIn.pushPose();
        matrixStackIn.translate(1,0,0);
        BlockRendererDispatcher rendererDispatcher = Minecraft.getInstance().getBlockRenderer();
        // get chest model
        BlockState state = Blocks.CHEST.defaultBlockState();
        rendererDispatcher.renderBlock(state,matrixStackIn,
                bufferIn, combinedLightIn, combinedOverlayIn, EmptyModelData.INSTANCE);
        matrixStackIn.popPose();

        matrixStackIn.pushPose();
        matrixStackIn.translate(0,1,0);
        ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
        // get diamond model
        ItemStack stack = new ItemStack(Items.DIAMOND);
        IBakedModel ibakedmodel = itemRenderer.getModel(stack, tileEntityIn.getLevel(), null);
        itemRenderer.render(stack, ItemCameraTransforms.TransformType.FIXED, true, matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn, ibakedmodel);
        matrixStackIn.popPose();
    }
}
